// 1.下载vue-router@3包
//2.引入vue-router包
import VueRouter from "vue-router";
import Vue from "vue";
import Login from "@/pages/Login";
import Home from "@/pages/Home";
import NotFound from "@/pages/NotFound";
import Movie from "@/pages/Home/Movie";
import Music from "@/pages/Home/Music";

//3.安装VurRouter插件
Vue.use(VueRouter)

//4.实例化VueRouter
const router = new VueRouter({
    mode:'history',
    routes:[
        {
            path:'/',
            redirect:'/home',
            name:'Home'
        },
        {
            path:'/home',
            component:Home,
            //方案三，在父级直接重定向
            redirect:'/home/movie',
            children:[
                {
                    path:'movie',
                    component:Movie,
                    name:'Movie'
                },
                {
                    path:'music',
                    component:Music,
                    name:'Music'
                },
            //    重定向:方案一：推荐
            //     {
            //         path:'',
            //         redirect:'movie'
            //     },
            //    方案二
            //     {
            //         path:'',
            //         component:Movie
            //     }
            ]
        },
        {
            path:'/login',
            component:Login,
            name:'Login'
        },
        //404
        {
            path:'/*',
            component:NotFound
        }
    ]
})

//5.导出路由器
export default router